import {MessageType} from "@/types/chat-message";

/**
 * 提取最后一条消息的文本内容
 * @param type
 * @param content
 */
export function extractLastMessageText(type: MessageType, content: any): string {
    if (typeof content === "string") content = JSON.parse(content);
    if (type === MessageType.TEXT) return content.text;
    switch (type) {
        case MessageType.IMAGE:
            return "[图片]";
        case MessageType.VIDEO:
            return "[视频】";
        case MessageType.AUDIO:
            return "[音频】";
        case MessageType.VOICE:
            return "[语音]";
        case MessageType.FILE:
            return "[文件]";
        case MessageType.REAL_AUDIO:
            return "[实时音频]";
        case MessageType.REAL_VIDEO:
            return "[实时视频]";
        case MessageType.USER:
            return "[用户信息]";
        case MessageType.EMOJI:
            return "[动画表情]";
        default:
            return "[未知格式消息]";
    }
}